home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 7
/
Aminet 7 - August 1995.iso
/
Aminet
/
comm
/
mebbs
/
directdl.lha
/
DirectDL.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-04-26
|
5KB
|
175 lines
/* DirectDL.c this program will allow specifying a file with the */
/* complete pathname and Mebbsnet will xfer the file and adjust */
/* the user's stats to reflect the download. */
/* */
/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING */
/* */
/* This door was written to allow me to easily download files */
/* remotely that I did not have in the BBS file catalogs. */
/* There are significant security risks involved in allowing */
/* indiscriminate downloading of your files. For example */
/* mebbsnet.con and the user.dat file contain confidential */
/* information that could leave your BBS or some of your user's */
/* confidential information vulnerable. */
/* */
/* For this reason a security.cfg file has been provided which */
/* should prevent the transfer of your user.dat and mebbsnet.con */
/* files. Additional security should be provided by linking this */
/* door program with access restrictions (ie MINACCESS 31) */
/* */
/* I eventually plan on expanding this program to allow its use */
/* in a CD-ROM file door. */
#include <exec/types.h>
#include <exec/libraries.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <fcntl.h>
#include <dos.h>
#include <dos/dos.h>
#include <proto/dos.h>
#include <proto/exec.h>
#include <ctype.h>
#include "mebbsutility.h"
#define DoorName "DirectDL"
struct Library *MEBBSUtilityBase = NULL;
void *LinkData;
void main (int, char **);
void CleanUp(void);
struct FileInfoBlock fileInfo;
BYTE FileName[255];
int error;
void main(int argc, char *argv[])
{
char PassString[120];
char WorkString[120];
UWORD LineNumber;
UWORD Data=0;
LONG NewData=0;
LONG FileLength;
LONG NewFiles=0;
FILE *fptr, *fopen();
char xfile[256];
char test[256];
char *p;
int x;
int q;
LineNumber = atoi(argv[1]);
if(!(MEBBSUtilityBase = OpenLibrary("mebbsutility.library",1L)))
{
printf("\nCould not open mebbsutility.library\n");
exit(20);
}
if(MEBBSUtilityBase->lib_Revision < 1)
{
CleanUp();
}
if(!(LinkData = LinkDoor(DoorName,LineNumber)))
CleanUp();
if(CheckCarrier(LinkData))CleanUp();
PrintString(LinkData,"",1);
PrintString(LinkData,"",1);
PrintString(LinkData,"Direct Download facility by Bob Scheel.",1);
PrintString(LinkData," Mebbsnet developer #M2017",1);
PrintString(LinkData,"",1);
NewData = GetUserInfo(LinkData,PassString,Data,SND_DOWNLOADBYTES);
NewFiles = GetUserInfo(LinkData,PassString,Data,SND_FILESDOWNLOADED);
sprintf(WorkString,"You have downloaded %ld bytes and %ld files.\n",NewData,NewFiles);
PrintString(LinkData,WorkString,1);
HotKeyPrompt(LinkData," Do you wish to download (y/N): ",PassString);
if(CheckCarrier(LinkData))CleanUp();
PrintString(LinkData,"",1);
strupr(PassString);
switch(PassString[0])
{
case 'Y':
Prompt(LinkData,"\nEnter full pathname ->",FileName,70);
if(CheckCarrier(LinkData))CleanUp();
if(FileName[0])
{
sprintf(xfile,"Doors:Directdl/Security.cfg");
p = strupr(FileName);
fptr=fopen(xfile,"ra");
if(CheckCarrier(LinkData))CleanUp();
if (fptr==0)
{
PrintString(LinkData,"* * * * * * * WARNING * * * * * * * * * *\n",1);
PrintString(LinkData," Security file couldn't be opened!\n",1);
PrintString(LinkData,"Program aborting to protect BBS security!\n",1);
CleanUp();
}
do
{
q = fscanf(fptr,"%s",test);
if (q>0)
{
p = strupr(test);
x = astcsma(FileName,test);
if (x) {
sprintf(PassString,"%s is a restricted file. Access denied.",FileName);
PrintString(LinkData,PassString,1);
CleanUp();
}
}
}
while (q>0);
fclose(fptr);
error = dfind(&fileInfo,FileName,0);
if (error == 0)
{
FileLength = fileInfo.fib_Size;
SendFile(LinkData,FileName);
NewData = FileLength + NewData;
NewFiles = NewFiles + 1;
EditUserInfo(LinkData,PassString,NewData,SND_DOWNLOADBYTES);
NewData = GetUserInfo(LinkData,PassString,Data,SND_DOWNLOADBYTES);
EditUserInfo(LinkData,PassString,NewFiles,SND_FILESDOWNLOADED);
NewFiles = GetUserInfo(LinkData,PassString,Data,SND_FILESDOWNLOADED);
PrintString(LinkData,"\n\n\nDownload Complete.",1);
if(CheckCarrier(LinkData))CleanUp();
sprintf(WorkString,"You have now downloaded %ld bytes and %ld files.\n",NewData,NewFiles);
PrintString(LinkData,WorkString,1);
if(CheckCarrier(LinkData))CleanUp();
}
}
break;
default:
PrintString(LinkData,"\n\n Changed your mind huh ;-)\n",1);
break;
}
CleanUp();
}
void CleanUp(void)
{
if(LinkData)CloseDoor(LinkData);
if(MEBBSUtilityBase)CloseLibrary(MEBBSUtilityBase);
exit(0);
}